//
//  HEMyApplyCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/12/9.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEMyApplyCell.h"

@interface HEMyApplyCell ()

@property (nonatomic, strong) UIImageView *goodsimgView;
@property (nonatomic, strong) UILabel *titleLb;
@property (nonatomic, strong) UILabel *deptLb;
@property (nonatomic, strong) UILabel *hospLb;

  
@property (nonatomic, strong) UILabel *stateLb;

@property (nonatomic, strong) UILabel *mainCntLb;
@property (nonatomic, strong) UILabel *audioResLb;
@property (nonatomic, strong) UILabel *remarkLb;
@property (nonatomic, strong) UILabel *remarkTitlLb;
@property (nonatomic, strong) UIView *warp;

@end

@implementation HEMyApplyCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.qmui_borderPosition = QMUIViewBorderPositionTop;
        self.qmui_borderWidth = 0.5;
        self.qmui_borderColor = CSplitLineColor;
     
        [self initUI];
    }
    return self;
}

- (void)initUI {
    
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    [self.contentView addSubview:warp];
    _warp = warp;
    
    warp.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    warp.layer.shadowColor = [UIColor colorWithRed:13/255.0 green:98/255.0 blue:218/255.0 alpha:0.08].CGColor;
    warp.layer.shadowOffset = CGSizeMake(0,5);
    warp.layer.shadowOpacity = 1;
    warp.layer.shadowRadius = 6;
    

    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(0);
        make.left.equalTo(self.contentView).mas_offset(0);
        make.right.equalTo(self.contentView).mas_offset(0);
        make.height.mas_greaterThanOrEqualTo(105);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
    }];
    
    // 商品图片
    _goodsimgView = [UIImageView new];
    _goodsimgView.image = IMAGE_NAMED(@"noImage");
    _goodsimgView.contentMode = UIViewContentModeScaleAspectFill;
    [warp addSubview:_goodsimgView];

    // 姓名
    _titleLb = [UILabel new];
    _titleLb.text = @"张三";
    _titleLb.font = DYBlodFont(18);
    [warp addSubview:_titleLb];

    // 科室
    _deptLb = [UILabel new];
    _deptLb.text = @"副主任医师 | 老年病科";
    _deptLb.font = DYFont(15);
    _deptLb.textColor = CNavSubTitleColor;
    [warp addSubview:_deptLb];

    // 所属医院
    _hospLb = [UILabel new];
    _hospLb.text = @"中南大学湘雅医院";
    _hospLb.font = DYFont(15);
    _hospLb.textColor = CNavLightBlackColor;
    [warp addSubview:_hospLb];
 
    //
    _stateLb = [UILabel new];
    _stateLb.text = @"-";
    _stateLb.font = DYBlodFont(15);
    _stateLb.textColor = CNavBgColor;
    _stateLb.textAlignment = NSTextAlignmentRight;
    [warp addSubview:_stateLb];
    
    
    // middle
    UILabel *mainCntLb = [UILabel new];
    mainCntLb.text = @"主诉内容：";
    mainCntLb.font = DYBlodFont(16);
    mainCntLb.textColor = CNavDargGrayColor;
    [warp addSubview: mainCntLb];
    
    UILabel *audioResLb = [UILabel new];
    audioResLb.text = @"审核原因：";
    audioResLb.font = DYBlodFont(16);
    audioResLb.textColor = CNavDargGrayColor;
    [warp addSubview: audioResLb];
    
    UILabel *remarkTitlLb = [UILabel new];
    remarkTitlLb.text = @"备注信息：";
    remarkTitlLb.font = DYBlodFont(16);
    remarkTitlLb.textColor = CNavDargGrayColor;
    [warp addSubview: remarkTitlLb];
    _remarkTitlLb = remarkTitlLb;
    
    _mainCntLb = [UILabel new];
    _mainCntLb.text = @"-";
    _mainCntLb.font = DYFont(16);
    _mainCntLb.textColor = CNavDargGrayColor;
    _mainCntLb.numberOfLines = 0;
    [warp addSubview:_mainCntLb];
    
    _audioResLb = [UILabel new];
    _audioResLb.text = @"-";
    _audioResLb.font = DYFont(16);
    _audioResLb.textColor = CNavDargGrayColor;
    _audioResLb.numberOfLines = 0;
    [warp addSubview:_audioResLb];
    
    _remarkLb = [UILabel new];
    _remarkLb.text = @"-";
    _remarkLb.font = DYFont(16);
    _remarkLb.textColor = CNavDargGrayColor;
    _remarkLb.numberOfLines = 0;
    [warp addSubview:_remarkLb];

    [_goodsimgView mas_makeConstraints:^(MASConstraintMaker *make) {
       make.top.equalTo(warp).mas_offset(15);
       make.left.equalTo(warp).mas_offset(15);
       make.width.height.mas_offset(72);
    }];
    _goodsimgView.layer.masksToBounds = YES;
    _goodsimgView.layer.cornerRadius = 36;

    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
       make.top.equalTo(_goodsimgView.mas_top);
       make.left.equalTo(_goodsimgView.mas_right).mas_offset(11);
    }];
    [_titleLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    [_titleLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];

    
    [_deptLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_titleLb.mas_bottom);
        make.left.equalTo(_titleLb.mas_right).mas_offset(10);
        make.right.equalTo(warp.mas_right).mas_offset(-10);
    }];
    
    [_stateLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_titleLb.mas_bottom);
        make.right.equalTo(warp).mas_offset(-10);
    }];
//    [_stateLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
 
  
    [_hospLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLb.mas_bottom).mas_offset(5);
        make.left.equalTo(_titleLb.mas_left);
        make.right.equalTo(warp).offset(-10);
    }];
  
    [mainCntLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_hospLb.mas_bottom).offset(10);
        make.left.equalTo(_titleLb.mas_left);
    }];
    [mainCntLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
 
    [audioResLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_mainCntLb.mas_bottom).offset(10);
        make.left.equalTo(_titleLb.mas_left);
    }];
    [audioResLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [remarkTitlLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_audioResLb.mas_bottom).offset(10);
        make.left.equalTo(_titleLb.mas_left);
    }];
    [remarkTitlLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    
    [_mainCntLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_hospLb.mas_bottom).offset(10);
        make.left.equalTo(mainCntLb.mas_right);
        make.right.equalTo(warp).offset(-10);
    }];
    
    [_audioResLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_mainCntLb.mas_bottom).offset(10);
        make.left.equalTo(audioResLb.mas_right);
        make.right.equalTo(warp).offset(-10);
    }];
    
    [_remarkLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_audioResLb.mas_bottom).offset(10);
        make.left.equalTo(remarkTitlLb.mas_right);
        make.right.equalTo(warp).offset(-10);
        make.bottom.equalTo(warp).offset(-10).priorityLow();
    }];
     
}

- (void)setModel:(HEApplyModel *)model {
    _model = model;
    
    [_goodsimgView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage: IMAGE_NAMED(@"hmang")];
    
    _titleLb.text = model.doctor_name;
    _deptLb.text = model.dept_name;
    _hospLb.text = model.hospital_name;
    
    _mainCntLb.text = model.user_note;
    _audioResLb.text = model.KAuditNote;
    _remarkLb.text = model.KDocNote;
    
    _stateLb.text = model.KStateText;
    _stateLb.textColor = model.KStateTextColor;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
